<?php
namespace app\admin\controller;

use app\common\model\SignManage as SignManageModel;
use app\common\controller\AdminBase;
use think\Db;
use think\Model;

class SignManage extends AdminBase
{
	protected $signManage_model;
	protected $user_model;


	protected function _initialize()
	{
		parent::_initialize();
		$this->signManage_model = new SignManageModel();
		$this->user_model = Model('user');

		$user_list = $this->user_model->where('status',1)->column('name','id');

		$this->assign('user_list',$user_list);
	}

	public function index($keyword = '', $page = 1)
	{
		$map = [];
		if($keyword){
			$user_findId = $this->user_model->where('status',1)->where('name',$keyword)->value('id');
			$map['user_id'] = $user_findId;
		}

		$signManage_list = $this->signManage_model->where($map)->order('id DESC')->paginate(15,false,['page' => $page]);

		return $this->fetch('index',['signManage_list'=>$signManage_list,'keyword'=>$keyword]);
	}

	public function delete($id = 0, $ids = [])
	{
		$id = $ids ? array_merge($ids) : $id;
		if($id){
			if($this->signManage_model->destroy($id)){
				return $this->success('删除成功');
			}else{
				return $this->error('删除失败');
			}
		}else{
			return $this->error('请选择需要删除的内容');
		}
	}
}